package com.iflysse.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.iflysse.dto.TeachingClassDto;
import com.iflysse.dto.TeachingClassUpdateDto;
import com.iflysse.entity.TeachingClass;
import com.iflysse.vo.TeachingClassDetailVo;

public interface TeachingClassDao {

    /**
     * 根据教师ID查询教师信息
     * @param accoteacherIduntId
     * @return
     */
    @Select("select * from tb_teaching_class where teacher_id = #{userId} and is_delete=0")
    List<TeachingClass> getTeacherClass(String userId);
    
    /**
     * 添加教学班级
     * @param teachingClassDto
     * @return
     */
    @Insert({"insert into tb_teaching_class (teaching_class_id,teacher_id,teaching_class_name,course_id) values(UUID(),#{userId},#{className},#{courseId})" })
    int addTeachingClass(TeachingClassDto teachingClassDto);
    /**
     * 删除教学班级
     * @param teachingClassDto
     * @return
     */
    @Update("update tb_teaching_class set is_delete=1 where teaching_class_id=#{classId} and teacher_id=#{userId}")
	int deleteTeachingClass(String userId,String classId);
    /**
     * 修改教学班级详情接口
     * @param teachingClassDto
     * @return
     */
    //@Update("update tb_teaching_class set teaching_class_name=#{className} where teaching_class_id=#{teachingClassId}")
	int updateTeachingClass(TeachingClassUpdateDto form);
    /**
     * 查询教学班级详情接口
     * @param teachingClassDto
     * @return
     */
   // @Select("select * from tb_teaching_class  where teaching_class_id = #{classId} and is_delete = 0")
    @Select("SELECT * FROM tb_teaching_class tc\r\n"
    		+ "LEFT JOIN tb_teacher t ON t.teacher_id=tc.teacher_id\r\n"
    		+ "LEFT JOIN tb_course c ON c.course_id=tc.course_id\r\n"
    		+ "WHERE tc.teaching_class_id=#{classId} AND tc.is_delete='0'")    
    TeachingClassDetailVo getTeachingClassByClassId(String classId);
    /**
     * 用于反射到查询教学班级详情接口
     * @param teachingClassDto
     * @return
     */
	@Select("select * from tb_course,tb_teacher WHERE tb_teacher.teacher_id=#{teacherId}")
	TeachingClass getCourseAndTeacherName(String teacherId);
    

}
